package cn.etynit.fallback;

import cn.etynit.exception.GlobalExceptionCodeEnum;
import cn.etynit.feign.MovieService;
import cn.etynit.result.JsonResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class MovieServiceFallbackFactory implements FallbackFactory<MovieService> {

    @Override
    public MovieService create(Throwable throwable) {
        return new MovieService() {
            @Override
            public JsonResult list() {
                return JsonResult.error(GlobalExceptionCodeEnum.ERROR);
            }

            @Override
            public JsonResult get(Long id) {
                return JsonResult.error(GlobalExceptionCodeEnum.ERROR);
            }

            @Override
            public JsonResult byMovie(Long movieId, Long count) {
                return JsonResult.error(GlobalExceptionCodeEnum.ERROR);
            }

            @Override
            public JsonResult giving(Long movieId, Long count, Long userId) {
                return JsonResult.error(GlobalExceptionCodeEnum.ERROR);
            }
        };
    }
}
